package com.wpfly.SpringBootDemo.service;

import com.wpfly.SpringBootDemo.dao.TeacherDao;
import com.wpfly.SpringBootDemo.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TeacherService {

    @Autowired
    private TeacherDao teacherDao;

    /**
     * 保存
     * @param teacher
     * @return
     */
    public Teacher save(Teacher teacher){
        return teacherDao.save(teacher);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    public Teacher find(Long id){
        return teacherDao.findById(id).orElse(new Teacher());
    }
}
